use axum::{
    routing::get,
    Router,
};
use log::{error, info, warn, trace, debug};
use log4rs;


#[tokio::main]
async fn main() {
    log4rs::init_file("log4rs.yaml", Default::default()).unwrap();
    let app = Router::new()
    .route("/foo", get(get_foo).post(post_foo))
    .route("/foo/bar", get(foo_bar))
    .route("/", get(root))
    .route("/root", get(|| async { "Hello, World!" }));

    // run it with hyper on localhost:3000
    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

async fn root() {
    trace!("detailed tracing info");
}
async fn get_foo() {
    warn!("warning message");
}
async fn post_foo() {
    error!("error message");
}
async fn foo_bar() {
    log::info!(target:"app","Input sys log");
    trace!("detailed tracing info");
    debug!("debug info");
    warn!("warning message");
    error!("error message");
}
